package com.xmkj.winmoney.activity;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.common.mvp.BaseMvpActivity;
import com.common.mvp.BasePresenter;
import com.common.retrofit.methods.JuadeMethods;
import com.common.retrofit.subscriber.CommonSubscriber;
import com.common.retrofit.subscriber.SubscriberListener;
import com.common.utils.EmptyUtils;
import com.common.widget.StarBarView;
import com.xmkj.winmoney.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/4/8.
 */

public class PingJiaActivity extends BaseMvpActivity {


    public static final String ORDERID = "orderid";
    @BindView(R.id.et_juade)
    EditText etJuade;
    @BindView(R.id.tv_submit)
    TextView tvSubmit;
    @BindView(R.id.fuwu_starbar)
    StarBarView fuwu_starbar;
    @BindView(R.id.zhejie_starbar)
    StarBarView zhejie_starbar;
    @BindView(R.id.yongshi_starbar)
    StarBarView yongshi_starbar;
    private String fuwu = "5";
    private String zhejie="5";
    private String yongshi= "5";
    String orderid = "102";

    @Override
    protected void setNavigation() {
        setNavigationBack("评价");
    }

    @Override
    protected BasePresenter createPresenterInstance() {
        return null;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_pingjia;
    }

    @Override
    protected void onViewCreated() {
         orderid =  getIntent().getStringExtra(ORDERID);
    }

    @Override
    protected void doLogicFunc() {

        attachClickListener(tvSubmit);
    }

    @Override
    protected void onViewClicked(View view) {
        if(view.getId()==tvSubmit.getId()){
            if(EmptyUtils.isEmpty(getEditTextStr(etJuade))){
                showToastMsg("请输入您的建议...");
                return;
            }
            gotoJuade();
        }
    }

    private void gotoJuade() {
        showProgressingDialog();
        CommonSubscriber<Object> subscriber = new CommonSubscriber<>(new SubscriberListener() {
            @Override
            public void onNext(Object o) {
                dismissProgressDialog();
                showToastMsg("评价成功");
                onBackPressed();
            }

            @Override
            public void onError(String e, int code) {
                dismissProgressDialog();
                showToastMsg(e);
            }
        });

        JuadeMethods.getInstance().saveData(subscriber,uid,hashid,orderid,(int) fuwu_starbar.getStarRating()+"",getEditTextStr(etJuade),(int) zhejie_starbar.getStarRating()+"",(int) yongshi_starbar.getStarRating()+"");
        rxManager.add(subscriber);
    }



    @Override
    public void bindKnife() {
        ButterKnife.bind(this);
    }


}
